#!/usr/bin/env ruby

LKP_SRC ||= ENV['LKP_SRC'] || File.dirname(File.dirname(File.dirname(__dir__)))

require "#{LKP_SRC}/lib/common.rb"

# Load and run tests from data file
File.readlines("#{LKP_SRC}/spec/url2cache_dir/data.txt").each_slice(3) do |input, expected|
  input = input.strip
  expected = expected.strip

  # Skip blank lines
  next if input.empty?

  # Run the function
  output = url2cache_dir(input)

  # Compare the output
  if output == expected
    puts "PASS: #{input} -> #{output}"
  else
    puts "FAIL: #{input}"
    puts "output: #{output}"
    puts "expect: #{expected}"
  end
end
